<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    /*本段函数控制小时、分钟、秒数的双位表示*/
    function checkTime(i) {
        if (i<10)
        {i="0"+i}
        return i
    }
</script>
<script type="text/javascript">
    var d = new Date() //新建一个Date对象
    var year = d.getFullYear() //获取年份
    var month = d.getMonth()+1 //获取月份
    var day = d.getDate() //获取日期
    var hour = d.getHours() //获取小时
    var min = d.getMinutes() //获取分钟
    var sec = d.getSeconds() //获取秒数
    document.write(year+"-"+month+"-"+day+" "+checkTime(hour)+":"+checkTime(min)+":"+checkTime(sec))
</script>
</body>
</html>